divUnp1   PROC NEAR32
; parameter 1: destination address
; parameter 2: address of 8 byte unpacked BCD number
; parameter 3: word w/ 1-digit BCD number as low-order byte
; author:  R. Detmer    revised:  5/98
          push ebp            ; establish stack frame
          mov  ebp, esp
          push esi            ; save registers
          push edi
          push eax
          push ebx
          push ecx
          mov  edi, [ebp+14]  ; destination address
          mov  esi, [ebp+10]  ; source address
          mov  bx, [ebp+8]    ; divisor
          mov  ah, 0          ; lastRemainder := 0
          mov  ecx, 8         ; count of bytes to process
forDiv:   mov  al, [esi]      ; digit from 8 byte number
          aad                 ; adjust to binary
          div  bl             ; divide by single byte
          mov  [edi], al      ; store quotient
          inc  esi            ; point at next digit of dividend
          inc  edi            ; and at next destination byte
          loop forDiv         ; repeat for all 8 bytes
          pop  ecx            ; restore registers
          pop  ebx
          pop  eax
          pop  edi
          pop  esi
          pop  ebp
          ret  10             ; return, discarding paramters
divUnp1   ENDP

